package com.journey.org.ui.login

import android.os.Bundle
import android.text.method.HideReturnsTransformationMethod
import android.text.method.PasswordTransformationMethod
import com.journey.org.BR
import com.journey.org.R
import com.journey.org.databinding.ActivityLoginBinding
import com.mvvmhabit.org.base.BaseActivity
import com.mvvmhabit.org.utils.StatusBarUtil

class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>() {

    private var isPasswordHide = true

    override fun onCreate(savedInstanceState: Bundle?) {
        StatusBarUtil.statusBarHide(this)
        super.onCreate(savedInstanceState)
    }

    override fun layoutId(savedInstanceState: Bundle?): Int = R.layout.activity_login

    override fun initVariableId(): Int = BR.viewModel

    override fun initViewModel(): Class<LoginViewModel> = LoginViewModel::class.java

    override fun initViewObservable() {
        super.initViewObservable()
        mBinding.ivPasswordSwitch.setOnClickListener {
            println("是否显示呢？")
            if (isPasswordHide) {
                // 显示为明文
                mBinding.edInputPassword.transformationMethod =
                    HideReturnsTransformationMethod.getInstance()
            } else {
                // 显示为密文
                mBinding.edInputPassword.transformationMethod =
                    PasswordTransformationMethod.getInstance()
            }
            isPasswordHide = !isPasswordHide
        }
    }

}